/**
 * 
 */
package com.feib.stms.model;

import java.math.BigDecimal;
import java.util.Date;
import java.util.Set;

import com.feib.stms.util.StmsUtil;

/**
 * @author Jimmy Liu
 *
 */
public class UploadFile extends AuditEntity 
{
	private static final long serialVersionUID = -1460773959009580141L;


	/**
	 * 上傳類別-交割款驗資檔
	 */
	public static final String UPLOAD_FILE_DELIVERY_PAYMENT_CHK = "1";

	/**
	 * 上傳類別-交割款資料檔
	 */
	public static final String UPLOAD_FILE_DELIVERY_PAYMENT = "2";

	/**
	 * 上傳類別-申購款資料檔
	 */
	public static final String UPLOAD_FILE_PURCHASE_PAYMENT = "3";

	/**
	 * 上傳類別-申購退款資料檔
	 */
	public static final String UPLOAD_FILE_PURCHASE_RETURN_PAYMENT = "4";
	
	
	
	/**
	 * 上傳類別-券商帳戶調撥
	 */
	public static final String UPLOAD_FILE_TRANSFER = "5";
	

	/**
	 * PK in Table
	 */
	private Long uploadFilePk;

	/**
	 * 所屬券商(非分公司); 便利查詢;
	 */
	private Group group;

	/**
	 * 上傳類別
	 */
	private String fileFormat;

	/**
	 * 上傳人員
	 */
	private User uploadUser;

	/**
	 * 上傳日期
	 */
	private Date uploadDate;

	/**
	 * 上傳檔名
	 */
	private String fileName;

	/**
	 * 上傳至Server後的檔名(完整路徑)
	 */
	private String filePathOnServer;

	/**
	 * 檔案狀態<br/>
	 * <ul>				
	 * <li>  0: 已上傳/待驗資/待審查(已轉入，尚未有任何人審查)</li>
	 * <li>  1. 第一次驗資中(驗資檔)</li>
	 * <li>  3. 第一次驗資完成(驗資檔)</li>
	 * <li>  5. 第二次驗資中(驗資檔)</li>
	 * <li>  7. 已驗資(驗資檔)</li>
	 * <li>  9. 轉交割(驗資檔轉交割檔，狀態歸屬在 已驗資)</li>
	 * <li> 10: 審查中(已有人員審查，但未達到審查人數門檻)</li>
	 * <li> 20: 已刪除/審查不通過(只要有一人審查不通過，即為審查不通過；明細應註記為刪除)</li>
	 * <li> 30: 已審查/待放行(檔案審查通過，所有審查人員皆對檔案審查通過)</li>
	 * <li> 40: 放行中(已有人員放行，但未達到放行人數門檻)</li>
	 * <li> 50: 已刪除/不放行(只要有一人不放行，即為放行不通過；明細應註記為刪除)</li>
	 * <li> 60: 已放行/待預約(即全數放行通過)</li>
	 * <li> 70: 已取消(即放行後反悔，要刪除；明細應註記為刪除)</li>
	 * <li> 80: 預扣中(即發送預扣電文，狀態歸屬在 已放行)</li>
	 * <li> 90: 已預扣(即收到預扣回覆檔案)</li>
	 * <li>100: 交易中(即銷帳批次執行中，狀態歸屬在 已預扣)</li> 
	 * <li>110: 已交易(即銷帳批次完成)<li>
	 * </ul>
	 */
	private Integer fileStatus;

	/**
	 * 交割日期或扣帳日期
	 */
	private Date deliveryDate;

	/**
	 * 券商代號<br/>
	 * EX:<ul>
	 * <li>218#.亞東總公司</li>
	 * <li>2180.亞東-台北</li>
	 * <li>2181.亞東-板橋</li></ol><br/>
	 * 來源:上傳檔案名稱中取得
	 */
	private String securitiesNo;

	/**
	 * 遠銀分行代號：4碼<br/>
	 * EX:0023.台北襄陽分行;<br/>
	 * 來源:上傳檔案名稱中取得;<br/>
	 * 無須檢核
	 */
	private String bankBracnchNo;

	/**
	 * 股票類別：H.一般上市櫃, R.興櫃, P.調撥;<br/>
	 * 來源:上傳檔案名稱中取得
	 */
	private String stockType;

	/**
	 * 處理類別; <br/>
	 * 來源:上傳檔案名稱中取得
	 */
	private String dealType;

	/**			
	 * 檔案序號：2碼 (從01開始)01,02...
	 */
	private String fileSn;
	
	/**
	 * 檔案的md5值
	 */
	private String fileMd5;

	/**
	 * 約定帳號
	 */
	private String preDesignatedAccount;

	/**
	 * 放行簽章值
	 */
	private String signerCert;

	/**
	 * 總筆數
	 */
	private Long totalItems;

	/**
	 * 總金額
	 */
	private BigDecimal totalAmount;

	/**
	 * 淨付金額
	 */
	private BigDecimal totalNetPay;

	/**
	 * 淨收金額
	 */	
	private BigDecimal totalNetIncome;

	/**
	 * 淨付筆數
	 */	
	private Long totalNetPayCount;

	/**
	 * 淨收筆數
	 */	
	private Long totalNetIncomeCount;

	/**
	 * 審查結果<ul>
	 * <li>True: 放行;</li>
	 * <li>False: 不放行;</ii>
	 * <li>Null: 未確認。</li></ul></br/>
	 * <strong>達設定門檻人數時,才須更新此欄位</strong>
	 */
	private Boolean checkResult;

	/**
	 * 審查人員
	 * <strong>達設定門檻人數時,才須更新此欄位</strong>
	 */
	private User checkUser;

	/**
	 * 所需審查人數;需達到券商流程設定門檻人數
	 * <strong>新增時將資料複製過來</strong>
	 */
	private Integer checkCount;

	/**
	 * 審查日期
	 * <strong>達設定門檻人數時,才須更新此欄位</strong>
	 */
	private Date checkDate;

	/**
	 * 放行結果<ul>
	 * <li>True: 放行;</li>
	 * <li>False: 不放行;</ii>
	 * <li>Null: 未確認。</li></ul></br/>
	 * <strong>達設定門檻人數時,才須更新此欄位</strong>
	 */
	private Boolean confirmResult;


	/**
	 * 放行人員
	 * <strong>達設定門檻人數時,才須更新此欄位</strong>
	 */
	private User confirmUser;

	/**
	 * 所需放行人數;需達到券商流程設定門檻人數
	 * <strong>新增時將資料複製過來</strong>
	 */
	private Integer confirmCount;

	/**
	 * 放行日期
	 * <strong>達設定門檻人數時,才須更新此欄位</strong>
	 */
	private Date confirmDate;

	/**
	 * 取消日期(資料取消功能使用)
	 */
	private Date cancelDate;

	/**
	 * 取消人員
	 */	
	private User cancelUser;
	

	/**
	 * 加解密基碼 
	 * <strong>DES固定英數字八碼 空白為上傳檔案不加密</strong>
	 */
	private String  desKey;
	
	
	/**
	 * 總檢核數
	 * <strong></strong>
	 */
	private Long chksum;
	
	
	
	/**
	 * 狀態中文名稱，顯示用<br/>
	 * Join CodeTable with codeKind='UPLOAD_FILE_STATUS'
	 */
	private String fileStatusName;
	
	/**
	 * 上傳類型中文名稱，顯示用<br/>
	 * Join CodeTable with codeKind='UPLOAD_FILE_FORMAT'
	 */
	private String fileFormatName;
	
	/**
	 * 顯示用<br/>
	 * 查詢時，最後一頁總計使用
	 */
	private Long recordCount;
	
	

	/**
	 * 交割款 驗資 申購 父類別
	 */
	private Set<BasePaymentFileContent> paymentFileContents;

	/**
	 * 調撥款 父類別
	 */
	private Set<Transfer> transfers;

	/**
	 * 檔案上傳操作紀錄
	 */
	private  UploadFileActionLog  uploadFileActionLog;
	
	
	

	public String getBankBracnchNo() {
		return bankBracnchNo;
	}

	public void setBankBracnchNo(String bankBracnchNo) {
		this.bankBracnchNo = bankBracnchNo;
	}

	public Date getCancelDate() {
		return cancelDate;
	}

	public void setCancelDate(Date cancelDate) {
		this.cancelDate = cancelDate;
	}

	public User getCancelUser() {
		return cancelUser;
	}

	public void setCancelUser(User cancelUser) {
		this.cancelUser = cancelUser;
	}

	public Integer getCheckCount() {
		return checkCount;
	}

	public void setCheckCount(Integer checkCount) {
		this.checkCount = checkCount;
	}

	public Date getCheckDate() {
		return checkDate;
	}

	public void setCheckDate(Date checkDate) {
		this.checkDate = checkDate;
	}

	public Boolean getCheckResult() {
		return checkResult;
	}

	public void setCheckResult(Boolean checkResult) {
		this.checkResult = checkResult;
	}

	public User getCheckUser() {
		return checkUser;
	}

	public void setCheckUser(User checkUser) {
		this.checkUser = checkUser;
	}

	public Integer getConfirmCount() {
		return confirmCount;
	}

	public void setConfirmCount(Integer confirmCount) {
		this.confirmCount = confirmCount;
	}

	public Date getConfirmDate() {
		return confirmDate;
	}

	public void setConfirmDate(Date confirmDate) {
		this.confirmDate = confirmDate;
	}

	public Boolean getConfirmResult() {
		return confirmResult;
	}

	public void setConfirmResult(Boolean confirmResult) {
		this.confirmResult = confirmResult;
	}



	public String getDealType() {
		return dealType;
	}

	public void setDealType(String dealType) {
		this.dealType = dealType;
	}

	public Date getDeliveryDate() {
		return deliveryDate;
	}

	public void setDeliveryDate(Date deliveryDate) {
		this.deliveryDate = deliveryDate;
	}

	public String getFileFormat() {
		return fileFormat;
	}

	public void setFileFormat(String fileFormat) {
		this.fileFormat = fileFormat;
	}

	public String getFileName() {
		return fileName;
	}

	public void setFileName(String fileName) {
		this.fileName = fileName;
	}

	public String getFilePathOnServer() {
		return filePathOnServer;
	}

	public void setFilePathOnServer(String filePathOnServer) {
		this.filePathOnServer = filePathOnServer;
	}

	public String getFileSn() {
		return fileSn;
	}

	public void setFileSn(String fileSn) {
		this.fileSn = fileSn;
	}

	public Integer getFileStatus() {
		return fileStatus;
	}

	public void setFileStatus(Integer fileStatus) {
		this.fileStatus = fileStatus;
	}

	public Group getGroup() {
		return group;
	}

	public void setGroup(Group group) {
		this.group = group;
	}

	public Set<BasePaymentFileContent> getPaymentFileContents() {
		return paymentFileContents;
	}

	public void setPaymentFileContents(
			Set<BasePaymentFileContent> paymentFileContents) {
		this.paymentFileContents = paymentFileContents;
	}

	public String getSecuritiesNo() {
		return securitiesNo;
	}

	public void setSecuritiesNo(String securitiesNo) {
		this.securitiesNo = securitiesNo;
	}

	public String getStockType() {
		return stockType;
	}

	public void setStockType(String stockType) {
		this.stockType = stockType;
	}

	public BigDecimal getTotalAmount() {
		return totalAmount;
	}

	public void setTotalAmount(BigDecimal totalAmount) {
		this.totalAmount = totalAmount;
	}

	public Long getTotalItems() {
		return totalItems;
	}

	public void setTotalItems(Long totalItems) {
		this.totalItems = totalItems;
	}

	public BigDecimal getTotalNetIncome() {
		return totalNetIncome;
	}

	public void setTotalNetIncome(BigDecimal totalNetIncome) {
		this.totalNetIncome = totalNetIncome;
	}

	public Long getTotalNetIncomeCount() {
		return totalNetIncomeCount;
	}

	public void setTotalNetIncomeCount(Long totalNetIncomeCount) {
		this.totalNetIncomeCount = totalNetIncomeCount;
	}

	public BigDecimal getTotalNetPay() {
		return totalNetPay;
	}

	public void setTotalNetPay(BigDecimal totalNetPay) {
		this.totalNetPay = totalNetPay;
	}

	public Long getTotalNetPayCount() {
		return totalNetPayCount;
	}

	public void setTotalNetPayCount(Long totalNetPayCount) {
		this.totalNetPayCount = totalNetPayCount;
	}

	public Set<Transfer> getTransfers() {
		return transfers;
	}

	public void setTransfers(Set<Transfer> transfers) {
		this.transfers = transfers;
	}

	public Date getUploadDate() {
		return uploadDate;
	}

	public void setUploadDate(Date uploadDate) {
		this.uploadDate = uploadDate;
	}

	public Long getUploadFilePk() {
		return uploadFilePk;
	}

	public void setUploadFilePk(Long uploadFilePk) {
		this.uploadFilePk = uploadFilePk;
	}

	public User getUploadUser() {
		return uploadUser;
	}

	public void setUploadUser(User uploadUser) {
		this.uploadUser = uploadUser;
	}

	/**
	 * @param uploadFileActionLog 的設定的 uploadFileActionLog
	 */
	public void setUploadFileActionLog(UploadFileActionLog uploadFileActionLog) {
		this.uploadFileActionLog = uploadFileActionLog;
	}

	/**
	 * @return uploadFileActionLog
	 */
	public UploadFileActionLog getUploadFileActionLog() {
		return uploadFileActionLog;
	}

	public String getFileFormatName() {
		return fileFormatName;
	}

	public void setFileFormatName(String fileFormatName) {
		this.fileFormatName = fileFormatName;
	}

	public String getFileStatusName() {
		return fileStatusName;
	}

	public void setFileStatusName(String fileStatusName) {
		this.fileStatusName = fileStatusName;
	}

	/**
	 * @param desKey 的設定的 desKey
	 */
	public void setDesKey(String desKey) {
		this.desKey = desKey;
	}

	/**
	 * @return desKey
	 */
	public String getDesKey() {
		return desKey;
	}

	/**
	 * @param chksum 的設定的 chksum
	 */
	public void setChksum(Long chksum) {
		this.chksum = chksum;
	}

	/**
	 * @return chksum
	 */
	public Long getChksum() {
		return chksum;
	}
	
	public String getFormatedChksum()
	{
		if (null == this.chksum)
			return null;
		
		return StmsUtil.getInstance().getFormatChecksum(chksum);
	}

	public void setConfirmUser(User confirmUser) {
		this.confirmUser = confirmUser;
	}

	public User getConfirmUser() {
		return confirmUser;
	}

	public String getFileMd5() {
		return fileMd5;
	}

	public void setFileMd5(String fileMd5) {
		this.fileMd5 = fileMd5;
	}

	public String getPreDesignatedAccount() {
		return preDesignatedAccount;
	}

	public String getFormatedPreDesignatedAccount()
	{
		if (null == this.preDesignatedAccount)
			return null;
		
		return StmsUtil.getInstance().getFormatedPreDesignatedAccount(preDesignatedAccount);
	}
	
	public void setPreDesignatedAccount(String preDesignatedAccount) {
		this.preDesignatedAccount = preDesignatedAccount;
	}

	public String getSignerCert() {
		return signerCert;
	}

	public void setSignerCert(String signerCert) {
		this.signerCert = signerCert;
	}

	/**
	 * @param recordCount 的設定的 recordCount
	 */
	public void setRecordCount(Long recordCount) {
		this.recordCount = recordCount;
	}

	/**
	 * @return recordCount
	 */
	public Long getRecordCount() {
		return recordCount;
	}

}
